{
LANG : PASCAL
PROB : fence
}

program FENCE;
const
  fi = 'fence.in';
  fo = 'fence.out';
       {answer.in}
  max = 501;
  maxc = 1025;
type
  integer = longint;
var
  a : array[1..max, 1..max] of integer;
  d : array[1..max] of integer;
  stack : array[1..maxc] of integer;
  p : array[1..maxc] of integer;
  n, m, min, top, start, l : integer;

procedure inp;
var
  i, u, v : integer;
begin
  read(m);
  n := 0;
  min := 10000;
  fillchar(a, sizeof(a), 0);
  for i := 1 to m do
  begin
    read(u, v);
    inc(a[u, v]);
    inc(a[v, u]);
    inc(d[u]);
    inc(d[v]);
    if u > n then n := u;
    if v > n then n := v;
    if u < min then min := u;
    if v < min then min := v;
  end;
end;

procedure init;
var
  i : integer;
begin
  start := 0;
  for i := 1 to n do
    if d[i] and 1 = 1 then
    begin
      start := i;
      break;
    end;
  if start = 0 then start := min;
  l := 0;
  top := 1;
  stack[top] := start;
end;

function get : integer;
begin
  get := stack[top];
end;

function pop : integer;
begin
  pop := stack[top];
  dec(top);
end;

procedure push(u : integer);
begin
  inc(top);
  stack[top] := u;
end;

procedure process;
var
  u, v : integer;
begin
  while top > 0 do
  begin
    u := get;
    for v := 1 to n do
      if a[u, v] > 0 then
      begin
        dec(a[u, v]);
        dec(a[v, u]);
        push(v);
        break;
      end;
    if u = get then
    begin
      inc(l);
      p[l] := pop;
    end;
  end;
end;

procedure out;
var
  i : integer;
begin
  for i := l downto 1 do writeln(p[i]);
end;

begin
  assign(input, fi); reset(input);
  assign(output, fo); rewrite(output);
  inp;
  init;
  process;
  out;
  close(output);
  close(input);
end.
